package com.woniu.product.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniu.product.dao.TUserCourseMapper;
import com.woniu.product.dto.TUserCourseDto;
import com.woniu.product.model.TUserCourse;
import com.woniu.product.service.TUserCourseService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 吴彦祖
 * @since 2024年04月02日
 */
@Service
public class TUserCourseServiceImpl extends ServiceImpl<TUserCourseMapper, TUserCourse> implements TUserCourseService {

    @Resource
    private TUserCourseMapper tUserCourseMapper;
    @Override
    public List<TUserCourseDto> queryMyStudent(Integer coachId) throws Exception {
        QueryWrapper<TUserCourse> wrapper = new QueryWrapper<>();
        wrapper.eq("coach_id",coachId);
        List<TUserCourse> list = tUserCourseMapper.selectList(wrapper);
        List<TUserCourseDto> dtos = BeanUtil.copyToList(list, TUserCourseDto.class);
        return dtos;
    }
}
